import store from "@/store";
import dayjs from 'dayjs';
export const formItemStyle = {
  paddingLeft: "20px",
};

export const cellStyle = {
  background: "rgba(28, 155, 252, 0.02)",
  color: "rgb(142, 155, 185)",
  textAlign: "center",
};

// 表头单元格样式
export const headerCellStyle = {
  background: "rgba(28, 155, 252, 0.02)",
  color: "rgb(142, 155, 185)",
  textAlign: "center",
};
// 表格内表单子样式
export const tableFormStyle = {
  marginBottom: 0,
};
export const formBase = [
  {
    label: '日期',
    type: 'daterange',
    field: 'shelfTime',
    required: true,
    otherOptions: {
      disabled: false,
      rangeSeparator: '至',
      startPlaceholder: '开始日期',
      endPlaceholder: '结束日期',
      pickerOptions: {
        shortcuts: [ {
          text: "今天",
          onClick(picker) {
            const end = dayjs().format("YYYY-MM-DD 23:59:59");
            const start = dayjs().format("YYYY-MM-DD 00:00:00");
            picker.$emit("pick", [start, end]);
          },
        },
          {
            text: "昨天",
            onClick(picker) {
              const end = new Date(dayjs().format("YYYY-MM-DD 23:59:59"));
              const start = new Date(dayjs().format("YYYY-MM-DD 00:00:00"));
              end.setTime(start.getTime() - 3600 * 1000 * 24);
              start.setTime(start.getTime() - 3600 * 1000 * 24);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近三天",
            onClick(picker) {
              const end = new Date(dayjs().format("YYYY-MM-DD 23:59:59"));
              const start = new Date(dayjs().format("YYYY-MM-DD 00:00:00"));
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 3);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近一周",
            onClick(picker) {
              const end = new Date(dayjs().format("YYYY-MM-DD 23:59:59"));
              const start = new Date(dayjs().format("YYYY-MM-DD 00:00:00"));
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近一个月",
            onClick(picker) {
              const end = new Date(dayjs().format("YYYY-MM-DD 23:59:59"));
              const start = new Date(dayjs().format("YYYY-MM-DD 00:00:00"));
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit("pick", [start, end]);
            },
          },]
      }
    }
  },
  {
    label: "店铺",
    type: "select",
    field: "shopId",
    optionsKey: "shopName",
    optionsValue: "id",
    options: store.state.custom_dict.shop,

  },
  {
    label: "目的地",
    type: "select",
    field: "destinationId",
    optionsKey: "destinationName",
    optionsValue: "destinationId",
    options: store.state.custom_dict.destination
  },
  {
    label: "货物类型",
    type: "select",
    field: "cargoId",
    optionsKey: 'cargoName',
    optionsValue: 'id',
    options: store.state.custom_dict.category,
  },
  {
    label: '仓库',
    type: 'select',
    field: 'warehouseId',
    optionsKey: "warehouseName",
    optionsValue: "id",
    options: store.state.custom_dict.warehouse,

  },
  {
    label: "时效",
    type: "select",
    field: "timelyId",
    optionsKey: "name",
    optionsValue: "id",
    options: store.state.custom_dict.timely,
  },
];

export const tableBase = [
  {
    label: "计算条件",
    prop: "calculationConditions",
    width: 200,
    operate: {
      type: "input",
      field: "calculationConditions",
    }
  },
  {
    label: "计算公式",
    prop: "formula",
    width: 200,
    operate: {
      type: "input",
      field: "formula",
    }
  },
  {
    label: "店铺",
    prop: "shopId",
    width: 150,
    operate: {
      required:true,
      type: "select",
      field: "shopId",
      optionsKey: "shopName",
      optionsValue: "id",
      options: store.state.custom_dict.shop,
      otherOptions: {
        multiple:true
      }
    },
  },
  {
    label: "仓库",
    prop: "warehouseId",
    width: 300,
    operate: {
      required:true,
      type: "select",
      field: "warehouseId",
      optionsKey: 'warehouseName',
      optionsValue: 'id',
      options: store.state.custom_dict.warehouse,
      otherOptions: {
        multiple:true
      }
    },
  },
  {
    label: "货物类型",
    prop: "cargoId",
    width: 300,
    operate: {
      required:true,
      type: "select",
      field: "cargoId",
      optionsKey: 'cargoName',
      optionsValue: 'id',
      options: store.state.custom_dict.category,
      otherOptions: {
        multiple:true
      }
    },
  },
  {
    label: "时效",
    prop: "timelyId",
    width: 300,
    operate: {
      required:true,
      type: "select",
      field: "timelyId",
      optionsKey: "name",
      optionsValue: "id",
      options: store.state.custom_dict.timely,
      otherOptions: {
        multiple:true
      }
    },
  },
  {
    label: "目的地",
    prop: "destinationId",
    width: 300,
    operate: {
      required:true,
      type: "select",
      field: "destinationId",
      optionsKey: "destinationName",
      optionsValue: "destinationId",
      options: store.state.custom_dict.destination,
      otherOptions: {
        multiple:true
      }
    },
  },
  {
    label: "费用类型",
    prop: "feeType",
    width: 200,
    operate: {
      type: "input",
      field: "feeType",
    }
  },
];
